<template>
	<view class="main">
		<view class="goods" v-for="item in goodsList" :key="item.itemid" @click.native="handleClick(item.itemid)">
			<image :src="item.itempic" mode="aspectFit" class="pic"></image>
			<view class="product">
				<view class="title">
					<text class="double-row">
						{{item.itemtitle}}
					</text>
				</view>
				<view class="num">
					<view class="price">￥{{item.itemendprice}}</view>
					<view class="old">￥{{item.itemprice}}</view>

					<view class="coupon-wrap">
						<view class="coupon" v-if="item.couponmoney != 0">{{item.couponmoney}}元券</view>
					</view>
				</view>
				<view class="revert">
					<template>
						<view class="commission font-blod">佣金￥{{ item.tkmoney}}</view>
					</template>
				</view>
				<view class="info">
					<view class="shop">
						<text class="name">{{item.shopname}}</text>
					</view>
					<view class="sales" >月销 {{item.itemsale}}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				goodsList: []
			}
		},
		methods: {
			// 获取列表
			getSalesList() {
				uni.request({
					url: "http://bbx.com/getSalesList",
					method: 'GET',
					success: (res) => {
						this.goodsList = res.data.data
					}
				})
			},
			// 跳转商品详情
			handleClick(itemId) {
				uni.navigateTo({
					url: `/pages/goods/goods?itemId=${itemId}`
				})
			}
		},
		onLoad() {
			this.getSalesList()
		}
	}
</script>


<style lang="scss">
	page {
		background-color: #F6F7F8;
	}

	.goods {
		width: 686rpx;
		box-sizing: border-box;
		background: #FFFFFF;
		display: flex;
		align-items: center;
		border-radius: 16rpx;
		margin: 0 auto;
		margin-bottom: 20rpx;
		padding: 12rpx;

		.pic {
			width: 220rpx;
			height: 220rpx;
			display: inline-block;
			margin-right: 16rpx;
			border-radius: 8rpx;
		}

		.product {
			.title {
				position: relative;
				width: 426rpx;
				color: #303133;
				font-size: 28rpx;
				font-weight: 600;
				margin-bottom: 18rpx;
			}


			.num {
				display: flex;
				align-items: center;
				margin-bottom: 8rpx;
				position: relative;

				.price {
					color: #FE395E;
					font-size: 32rpx;
					font-weight: bold;
					margin-right: 8rpx;
				}

				.old {
					text-decoration: line-through;
					color: #909399;
					font-size: 24rpx;
					margin-right: 166rpx;
				}

				.sales {
					color: #909399;
					font-size: 22rpx;
				}

				.coupon-wrap {
					position: absolute;
					top: 0;
					right: 12rpx;

					.coupon {
						font-size: 20rpx;
						background: #FE395E;
						padding: 2rpx 12rpx;
						position: relative;
						color: #FFFFFF;
						border-radius: 4rpx;

						&::before {
							position: absolute;
							content: "";
							width: 10rpx;
							height: 10rpx;
							background: #FFFFFF;
							border-radius: 50%;
							left: -6rpx;
							top: 14rpx;
						}

						&::after {
							position: absolute;
							content: "";
							width: 10rpx;
							height: 10rpx;
							background: #FFFFFF;
							border-radius: 50%;
							right: -6rpx;
							top: 14rpx;
						}
					}
				}
			}

			.revert {
				display: flex;
				font-size: 20rpx;
				margin-bottom: 14rpx;

				.commission {
					background: linear-gradient(225deg, #FDAF1C 0%, #FE395E 100%);
					border-radius: 4rpx;
					padding: 2rpx 8rpx;
					color: #fff;
					margin-right: 8rpx;
				}

				.point {
					background: #ffecef;
					border-radius: 4rpx;
					padding: 2rpx 8rpx;
					color: #303133;

					.text {
						margin-left: 8rpx;
						color: #fe395e;
					}
				}
			}

			.info {
				display: flex;
				justify-content: space-between;
				align-items: center;

				.shop {
					display: flex;
					justify-content: flex-start;
					align-items: center;

					.shop-mini {
						width: 20rpx;
						height: 20rpx;
					}

					.name {
						color: #909399;
						font-size: 22rpx;
						font-weight: 400;
					}
				}

				.sales {
					font-size: 22rpx;
					font-weight: 400;
					color: #909399;
				}
			}
		}
	}
</style>
